From c86f0b1b237bf8ccc47a5a5399a8acc55e0eb1fd Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 10 Sep 2015 18:48:29 -0400 Subject: [PATCH] bitmask: Optimize no-op resizes Statistics for the gtk3-demo listbox example show that the vast majority of calls to _gtk_allocated_bitmask_resize go from a size of 2 to 2. Don't needlessly call realloc() in this case. --- gtk/gtkallocatedbitmask.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gtk/gtkallocatedbitmask.c b/gtk/gtkallocatedbitmask.c index 567b86cb91..0950d4362d 100644 --- a/gtk/gtkallocatedbitmask.c +++ b/gtk/gtkallocatedbitmask.c @@ -52,6 +52,9 @@ gtk_allocated_bitmask_resize (GtkBitmask *mask, { gsize i; + if (size == mask->len) + return mask; + mask = g_realloc (mask, sizeof (GtkBitmask) + sizeof(VALUE_TYPE) * (size - 1)); for (i = mask->len; i < size; i++) -- 2.30.2